package com.wlyuan.open.scanner.utils.enums;

import com.wlyuan.core.marker.NamedValue;
import com.wlyuan.core.marker.NamedValueMap;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Map;
import java.util.Optional;

/**
 * @author lijing
 * description 是否自动委托对账枚举
 */
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
public enum AutoBalanceEnum implements NamedValue<Integer> {
    OPEN(0, 1, "开启"),
    CLOSE(1, 0, "关闭");;

    private final Integer value;
    private final Integer newValue;
    private final String name;

    private static final Map<Integer, AutoBalanceEnum> MAP = new NamedValueMap<>(AutoBalanceEnum.class);

    public static AutoBalanceEnum fromValue(Integer value) {
        return Optional.ofNullable(MAP.get(value)).orElse(CLOSE);
    }
}
